Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AttributeError on login #586

Merged
merged 1 commit into from
Jun 8, 2020
Merged

Conversation

qwertyuu
Copy link

@qwertyuu qwertyuu commented Jun 1, 2020

Facebook decided they needed an "Accept" header to return data on request and that broke fbchat

@qwertyuu qwertyuu changed the title Fix TypeError on login Fix AttributeError on login Jun 1, 2020
@qwertyuu
Copy link
Author

qwertyuu commented Jun 1, 2020

Seems to fix:
#584
#567
#555
#551
#565

Maybe fixes
#556
Callen93 confirmed that it was not fixed by this PR (yet) 🤷

@Callen93
Copy link

Callen93 commented Jun 2, 2020

Hello,
I don't know if it's the right place to discuss this but as it seems to exists multiple login/logout problem right now I want to expose some conclusion and try to find solution. Thank you by the way for this fix.

I think the update of facebook with new UI did broke a lot of things. The thing is activating/desactivating the UI change (or at least changed) the behaviour of facebook against fbchat. For instance on friday (can't reproduce today), I could login with fbchat only when I desactivated new UI. So one fix can work for people with old UI and not people with new UI.

Lets first focus on branch carpedm20:v1 :

On master version, it's a bit worse. I used your change on master version and get

  • When trying to connect with session cookies fbchat.NotLoggedIn: Found empty fb_dtsg, the session was probably invalid.
  • If trying to apply proposed changes in Change method search fb_dtsg #552 same problem but message error is fbchat.NotLoggedIn: Could not find fb_dtsg
  • When trying to connect via login/password, It still fail and block temporary my account.

I'm still trying to investigate on this and come back at you if I find something interesting.

@qwertyuu
Copy link
Author

qwertyuu commented Jun 2, 2020

@Callen93 Things I can tell you about my setup and why it fixed the problems I had:

  1. I am not using the new Facebook UI
  2. I do not have 2FA (just stating this makes me want to enable it, I feel like someone will scan through the github comments and try to hack me)

I went through the real messenger.com and saw that the headers differed from what the "Sessions" client headers tried to send to facebook. By replicating my browser's headers, I was able to get a response in brotli form. When I commented out all the unnecessary headers, I ended up with only the one I uploaded through the fix. My initial problem was 'NoneType' object has no attribute 'group' and it happened because r.text at that place was an empty string (facebook just didn't respond any content but it as a 200 OK response anyways). You are right, I think all these login/logout problems are from the new UI update and may have impacted the old one too.

@madsmtm
Copy link
Member

madsmtm commented Jun 7, 2020

Hmm, we're using requests, which should set the Accept: */* pr. default, which is the same thing browsers do! So I don't really understand this, are you sure this actually fixes anything, and isn't just by coincidence that it suddenly worked?

Regarding the new UI, that is partly the reason why I changed the login logic on the master branch to use messenger.com urls, see 079d409. Haven't had the time to backport a lot of the fixes (and bugs) in there to v1, so that's the primary reason v1 can't handle the new UI

@madsmtm
Copy link
Member

madsmtm commented Jun 7, 2020

Theory: Using Accept: text/html triggers legacy code, so that the new UI isn't activated?

@qwertyuu
Copy link
Author

qwertyuu commented Jun 8, 2020

are you sure this actually fixes anything, and isn't just by coincidence that it suddenly worked?

This is a hard question because I don't have time to test it elsewhere and it's hard to be sure unless many others try it and report back as positive. In my case it was a causal effect: adding that line made fbchat login, while removing it had a devastating effect (empty response body so all the regexes fired on an empty string)

The only way I can be pretty sure it works is that @Callen93 tried it and reported back as positive, and this is the closest I can be to being sure it at least fixes the login procedure.

@madsmtm
Copy link
Member

madsmtm commented Jun 8, 2020

Well, I think that's good enough for me, I'll take it, thanks!

@madsmtm madsmtm merged commit 86d7220 into fbchat-dev:v1 Jun 8, 2020
@qwertyuu qwertyuu deleted the fix-typeerror-v1 branch June 8, 2020 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants